<template>
  <div>
    <my-form ref="form" style="width: 500px;" class="app-container" :fields="add_fields" @my-form-cancel="my_form_cancel" @my-form-sure="my_form_sure" />
  </div>
</template>

<script>
import myForm from '@/components/my-form/index'
import add_fields from '../configs/add'
import { add, add_classify_service } from '../api'

export default {
  components: {
    myForm
  },
  data: function() {
    return {
      add_fields
    }
  },
  methods: {
    async my_form_sure(data) {
      // {"project_name":"联合交易平台","productid":"pcb_uniontrans","spaceid":"pcb_uniontrans","systemid":"10201","client_type":"web","refsystemid":"12","axure":"http://192.168.1.238/pcb_uniontrans-axure","preview":"", "nodejs":"http://192.168.1.238:8889"}
      const project_info = await add(data)
      const res = await add_classify_service(project_info.project_id, data.spaceid, data.client_type, data.project_name)
      if (res.code === 1) {
        this.$message({
          message: '新增项目成功',
          type: 'success',
          duration: 2 * 1000
        })
        this.$router.back()
        return
      }
    },
    my_form_cancel() {
      this.$router.back()
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
